<template>
  <section class="section sec-7" id="sec-7">
    <main>
      <div class="co-title-balls"></div>
      <h1 class="co-title">联系我们</h1>
      <div class="co-lr-part">
        <div class="left">
          <h2>发送留言到我们信箱:</h2>
          <input type="email" placeholder="your@email.com" v-model="email" />
          <textarea cols="30" rows="2" placeholder="message..." v-model="content"></textarea>
          <button class="co-btn arrow small" @click="handleSend">发送</button>
          <a href="mailto:works@keenoho.space">也可以直接写邮件发送到 <span>works@keenoho.space</span> </a>
        </div>
        <div class="right">
          <h2>关注我们的公众号:</h2>
          <div>
            <img src="/qrcode.jpg" />
          </div>
        </div>
      </div>
    </main>
  </section>
</template>
<script>
export default {
  name: 'co-section-7',
  data() {
    return {
      email: '',
      content: '',
    };
  },
  methods: {
    async handleSend() {
      if (!this.email.trim().length && !this.content.trim().length) {
        alert('请填写留言再进行发送');
        return;
      }
      await this.$sdk.request({
        method: 'POST',
        url: '/v1/mail/send',
        data: {
          from: this.$config.CONFIG_APP_ID,
          to: 'works@keenoho.space',
          title: this.$config.CONFIG_APP_NAME,
          content: `email: ${this.email}
content: ${this.content}`,
        },
      });
      alert('发送成功, 感谢你的留言, 我们会尽快回复');
    },
  },
};
</script>
<style lang="less" scoped>
.sec-7 {
  .co-lr-part {
    margin-top: 40px;
  }

  .left {
    h2 {
      font-size: 20px;
      font-weight: bold;
    }

    input {
      font-size: 28px;
      font-weight: bold;
      background-color: transparent;
      border: 0;
      border-bottom: 1px solid #9c9c9c;
      outline: 0;
      display: block;
      margin-top: 20px;
      color: #fff;
      width: 500px;
    }

    textarea {
      font-size: 28px;
      font-weight: bold;
      background-color: transparent;
      border: 0;
      border-bottom: 1px solid #9c9c9c;
      outline: 0;
      display: block;
      margin-top: 30px;
      color: #fff;
      line-height: 1.55;
      width: 500px;
    }

    button {
      display: block;
      margin-top: 30px;
      width: 120px;
    }

    a {
      display: block;
      margin-top: 30px;
      color: #999;
      font-size: 14px;

      span {
        font-size: 16px;
        text-decoration: underline;
        color: #e1e1e1;
        transition: opacity 0.2s linear;
        &:hover {
          opacity: 0.8;
        }
      }
    }
  }

  .right {
    padding-left: 40px;
    h2 {
      font-size: 20px;
      font-weight: bold;
    }

    div {
      display: flex;
    }

    img {
      display: block;
      width: 220px;
      height: 220px;
      border-radius: 16px;
      margin-top: 20px;

      & + img {
        margin-left: 40px;
      }
    }
  }
}

@media screen and (max-width: 1000px) {
  .sec-7 {
    .left {
      h2,
      a {
        text-align: center;
      }
      input,
      textarea {
        width: 100%;
      }
      button {
        margin: 30px auto 30px;
      }
    }
    .right {
      margin-top: 40px;
      padding-left: 0;

      h2 {
        text-align: center;
      }

      img {
        margin: 30px auto 30px;
      }
    }
  }
}
</style>
